define(['jquery'],() => {
	class Greycar {
		constructor() {
		    this.loadHtml()
			this.calcarcoun()
			this.dianj ()
		}
		loadHtml () {
			// console.log('load')
			return new Promise(resolve => {
			$('#greycar').load('/html/modules/greycar.html')
			})
			
		}
		calcarcoun (){
			let count = 0
			let cart = localStorage.getItem('cart')
			
			console.log($('#trolley_num'))
			if(cart){
				cart = JSON.parse(cart)
				count = cart.reduce((num,shop) => {
					return num +shop.count
				},0)
			}
			
			$('#shop_car_num').html(count)
			
		}
		dianj (){
			$('.shop_right_car').on('click',() => {
				location.href = '/html/myshopcar.html'
			})
		}
	}
	return new Greycar
})